package com.zoe.onelink.ratelimit.sepc.model;

import com.zoe.onelink.common.entity.ResultVO;
import com.zoe.onelink.common.enumeration.ExceptionCodeEnum;
import com.zoe.onelink.util.StrUtil;

/**
 * <p>标题: </p>
 * <p>描述: </p>
 * <p>版权: Copyright (c) 2022</p>
 * <p>公司: 智业软件股份有限公司</p>
 *
 * @version: 1.0
 * @author: ruansheng
 * @date: 2022-12-07
 */
public class DefaultRateLimitFailureResultProvider implements RateLimitFailureResultProvider {

    private static final ResultVO<String> DEFAULT_FAILURE_RESULT = ResultVO.failure(ExceptionCodeEnum.REQUEST_LIMITING, "请求过于频繁", "");

    @Override
    public Object getFailureResult(String failureMsg) {
        if (StrUtil.isBlank(failureMsg)) {
            return DEFAULT_FAILURE_RESULT;
        }
        return ResultVO.failure(failureMsg);
    }
}
